const path = require("path");
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
module.exports={
  mode:"production",
  entry:"./src/index.js",
  output:{
    path:path.resolve(__dirname,"lib"),
    filename:"index.js",
    library:"bc000001",// 在全局变量中增加一个library变量
    libraryTarget:"umd",
    libraryExport: "default", // 对外暴露default属性，就可以直接调用default里的属性
    globalObject: 'this', // 定义全局变量,兼容node和浏览器运行，避免出现"window is not defined"的情况
    umdNamedDefine: true
  },
  module: {
    rules: [{
      test: /\.js$/,
      include: [
        path.resolve(__dirname, 'src')
      ],
      exclude: /(node_modules|bower_components)/,
      loader: "babel-loader",
    }]

  },
  plugins: [
    new NodePolyfillPlugin()
  ]
}

